'use strict';
//引入样式文件
import './styles/app.scss';
import './styles/iBar.scss';
import './styles/footer.scss';
import './styles/todayTab.scss';
import './store/types';

import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
//路由器
import {Router, browserHistory, Route, IndexRoute} from 'react-router';
//reducers 规则
import reducers from './reducers/reducers';
//路由列表 声明
import frontEndRoutes from './frontEndRoutes';
import backstageRoutes from './backstageRoutes';
//thunk 中间件
import reduxThunk from 'redux-thunk';

const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);
const store = createStoreWithMiddleware(reducers);
// 引入单个页面，非嵌套页面（login）
import login from './pages/frontEnd/login.js';
// 引入单个页面，非嵌套页面（registered）
import registered from './pages/frontEnd/registered.js';
// 引入单个页面，非嵌套页面（前端首页）
import indexHome from './pages/frontEnd/indexHome.js';
// 引入单个页面，非嵌套页面（后台首页）
import backstageLogin from './pages/backstage/login.js';
// antd 国际化
import { LocaleProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
//主页面渲染入口
ReactDOM.render(
  <LocaleProvider locale={zh_CN}>
    <Provider store={store}>
        <Router history={browserHistory}>
          <Route path="login" component={login} />
          <Route path="registered" component={registered} />

          <Route path="/" component={indexHome}>
            {frontEndRoutes}
          </Route>
          <Route path="backstage" component={backstageLogin}>
            {backstageRoutes}
          </Route>
        </Router>
    </Provider>
  </LocaleProvider>
, document.getElementById('app'));
